# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=fnlfmt
pkgver=0.3.2
pkgrel=0
pkgdesc="A formatter for Fennel code"
url="https://git.sr.ht/~technomancy/fnlfmt"
arch="noarch"
license="MIT"
depends="lua5.4 fennel-lua"
makedepends="fennel5.4"
subpackages="$pkgname-doc $pkgname-lua:_lua"
source="$pkgname-$pkgver.tar.gz::https://git.sr.ht/~technomancy/fnlfmt/archive/$pkgver.tar.gz"

build() {
	FENNEL=/usr/bin/fennel5.4 make fnlfmt
	FENNEL=/usr/bin/fennel5.4 make fnlfmt.lua
}

check() {
	FENNEL=/usr/bin/fennel5.4 make test
}

package() {
	install -Dm755 "$builddir"/fnlfmt "$pkgdir"/usr/bin/fnlfmt

	install -Dm644 "$builddir"/fnlfmt.1 "$pkgdir"/usr/share/man/man1/fnlfmt.1
	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/fnlfmt/LICENSE
}

_lua() {
	local dir="$subpkgdir"/usr/share/lua/common
	local rockdir="$subpkgdir"/usr/lib/luarocks/rocks-common/"$pkgname"/"$pkgver-1"
	mkdir -p "$dir" "$rockdir"
	cp "$builddir"/fnlfmt.lua "$dir"
	echo 'rock_manifest = {}' > "$rockdir"/rock_manifest
}

sha512sums="
024ae236e8c81835151d99730fecd7b9cb69efe42b8ac89453ca96dca3cb82cbaa6b78b7bac3df46fd8d90fe3577c9afcff9ae1b0f486d6fa9da0a3f1cacdbf0  fnlfmt-0.3.2.tar.gz
"
